package com.xxin.controller;

import com.xxin.pojo.entity.MedicalAdvice;
import com.xxin.pojo.vo.PatientVO;
import com.xxin.service.MedicalAdviceService;
import com.xxin.service.PatientService;
import com.xxin.service.RegistryService;
import jakarta.annotation.Resource;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author 小欣
 * @version 1.0
 * @since 1.8
 */
@Controller
@RequestMapping("/api/consultation")
public class PatientController {
	
	private final Logger log = LogManager.getLogger(PatientController.class);
	
	
	@Resource
	private PatientService patientService;
	
	@Resource
	private MedicalAdviceService medicalAdviceService;
	
	@Resource
	private RegistryService registryService;
	
	/**
	 * 跳转问诊页面
	 */
	@GetMapping("/consultationAdd")
	public String consultationAdd(@RequestParam("id") Long id, Model model){
//		log.info("")
		log.info("开始问诊---> 挂号单编号:{}",id);
		PatientVO patientVO = patientService.getInfoByRegistryId(id);
		model.addAttribute("register",patientVO);
		return "consultationAdd";
	}
	
	/**
	 * 问诊结束
	 */
	@PostMapping("/consultationEnd")
	public String consultationEnd(MedicalAdvice medicalAdvice){
		registryService.consultationEnd(medicalAdvice.getRegistryId());
		return "redirect:/api/register/registerInfoList";
	}
}
